#include<bits/stdc++.h>
using namespace std;
int a[200001],n;
int main(){
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    int T;
    cin>>T;
    for(int fck=1;fck<=T;fck++){
        int ans=0;
        cin>>n;
        for(int i=1;i<=n;i++){
            cin>>a[i];
            for(int j=1;j<=i;j++){
                if(a[i]==a[j])ans+=a[i];
            }
        }
        
        cout<<ans<<endl;
    }
    return 0;
}